package com.hxzy.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 前端构造的树型选择
 */
@Getter
@Setter
public class TreeSelect implements Serializable {

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<TreeSelect> children;

    public TreeSelect() {
    }


    public TreeSelect(SysMenuVO menu){
        this.id = menu.getMenuId();
        this.label = menu.getMenuName();
        if(menu.getChildren()!=null) {
            this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        }
    }

}
